"""
Steam交易管理模块
提供启动和停止Steam交易状态刷新定时任务的接口
"""
import logging
from biz.steam_trade_status_scheduler import get_scheduler

logger = logging.getLogger(__name__)

def start_trade_status_refresh():
    """启动Steam交易状态刷新定时任务"""
    logger.info("启动Steam交易状态刷新定时任务")
    scheduler = get_scheduler()
    scheduler.start()
    return True

def stop_trade_status_refresh():
    """停止Steam交易状态刷新定时任务"""
    logger.info("停止Steam交易状态刷新定时任务")
    scheduler = get_scheduler()
    scheduler.stop()
    return True

def is_trade_status_refresh_running():
    """检查Steam交易状态刷新定时任务是否正在运行"""
    scheduler = get_scheduler()
    return scheduler.running


if __name__ == "__main__":
    # 配置日志
    logging.basicConfig(
        level=logging.INFO,
        format='%(asctime)s - %(name)s - %(levelname)s - %(message)s'
    )
    
    # 测试启动和停止
    try:
        # 启动定时任务
        start_trade_status_refresh()
        logger.info("定时任务已启动，按Enter停止")
        
        # 等待用户输入
        input()
        
    except KeyboardInterrupt:
        logger.info("收到停止信号")
    finally:
        # 停止定时任务
        stop_trade_status_refresh()
        logger.info("定时任务已停止")
